<?php

namespace app\common\controller;


use app\BaseController;
use app\api\service\SignService;
use think\exception\HttpException;

class ApiController extends BaseController
{
    // 跳过验签的方法
    protected $noNeedSign = [
        'doPoints',
    ];

    protected function initialize()
    {
        $action = request()->action();

        if (!in_array($action, $this->noNeedSign)) {
            $this->verifySign();
        }
    }

    protected function verifySign()
    {
        $params = request()->param();
      
        if (!SignService::verifySign($params)) {
            output_error('签名验证失败');
        }
    }
}